package com.ruoyi.web.controller.zhuangxiucontroller.shopController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.ProductLabel;
import com.ruoyi.system.service.zhaungxiuservice.shopService.ProductLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/shopping/label")
public class ProductLabelController extends BaseController {

    @Autowired
    private ProductLabelService productLabelService;

    @PreAuthorize("@ss.hasPermi('shopping:label:addlab')")
    @Log(title = "商品标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductLabel productLabel)
    {
        Integer numproductId = productLabel.getNumproductId();
        productLabel.setProductId(numproductId);
        Integer numproductPicId = productLabel.getNumproductPicId();
        productLabel.setProductPicId(numproductPicId);
        productLabel.setModifiedTime(new Date());
        return toAjax(productLabelService.insertProductLabel(productLabel));
    }

    @PreAuthorize("@ss.hasPermi('shopping:label:editlabaa')")
    @Log(title = "商品标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductLabel productLabel)
    {
        return toAjax(productLabelService.updateProductLabel(productLabel));
    }


}
